package com.jetpack.mvvm.lib.net

import android.app.Application
import android.util.Log
import com.jetpack.mvvm.lib.common.inter.InterAppModel
import com.jetpack.mvvm.lib.module.annotation.AppModel
import java.lang.ref.WeakReference

@AppModel
object NetModule: InterAppModel {
    var appContext: WeakReference<Application> = WeakReference(null)
    val application: Application
        get() {
            return appContext.get() ?: throw IllegalArgumentException("Application should be set first")
        }


    override fun initModule(app: Application) {
        Log.d("NetModule", "initModule")
        appContext = WeakReference(app)
    }
}